import 'dart:convert';
import 'package:spring_fairy/model/mood_type.dart';
import 'api.dart';

class MoodTypeAPI extends API {
  Future<MoodType?> createMoodType(MoodType moodType) async {
    var response = await sendJSONPostRequest("/moodtypes/create", moodType.toJson());
    if(response == null) {
      return null;
    }
    return MoodType.fromJson(json.decode(response));
  }

  Future<List<MoodType>?> getAllMoodTypes() async {
    var response = await sendGETRequest("/moodtypes/list");
    if(response == null) {
      return null;
    }
    print(response);
    var list = json.decode(response);
    var result = <MoodType>[];

    for(var i = 0 ; i < list.length ; i++) {
      result.add(MoodType.fromJson(list[i]));
    }
    return result;
  }


}